import type { BasicTableColumn } from '@/components/table';
import TableFieldType from '@/components/table/src/types/field-type';
import type { FormSchema } from '@/components/form';
import FormFieldType from '@/components/form/src/types/field-type';

export const columns: BasicTableColumn[] = [
  {
    title: 'postId',
    key: 'postId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: 'deptId',
    key: 'deptId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '岗位编码',
    key: 'postCode',
    fieldType: TableFieldType.TEXT,
    fixed: 'left',
  },
  {
    title: '岗位名称',
    key: 'postName',
    fieldType: TableFieldType.TEXT,
    sort: 1,
  },
  {
    title: '类别编码',
    key: 'postCategory',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '岗位排序',
    key: 'postSort',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '状态',
    key: 'status',
    fieldType: TableFieldType.TAG,
    width: 100,
    align: 'center',
    tagOptions: {
      options: [
        {
          label: '正常',
          value: '0',
          type: 'success',
        },
        {
          label: '停用',
          value: '1',
          type: 'error',
        },
      ],
    },
  },
  {
    title: '备注',
    key: 'remark',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '部门名',
    key: 'deptName',
    fieldType: TableFieldType.TEXT,
    sort: 3,
  },
];

export const formSchemas: FormSchema[] = [
  {
    field: 'postId',
    component: FormFieldType.INPUT,
    label: 'postId',
    display: false,
  },
  {
    field: 'deptId',
    component: FormFieldType.TREE_SELECT,
    label: '所属部门',
    componentProps: {
      shareDataKey: 'departmentTreeData',
      defaultFirst: true,
    },
    rules: [{ required: true }],
  },
  {
    field: 'belongDeptId',
    component: FormFieldType.INPUT,
    label: 'belongDeptId',
    display: false,
  },
  {
    field: 'postCode',
    component: FormFieldType.INPUT,
    label: '岗位编码',
    rules: [{ required: true }],
  },
  {
    field: 'postName',
    component: FormFieldType.INPUT,
    label: '岗位名称',
    rules: [{ required: true }],
  },
  {
    field: 'postCategory',
    component: FormFieldType.INPUT,
    label: '岗位类别编码',
  },
  {
    field: 'postSort',
    component: FormFieldType.INPUT_NUMBER,
    label: '排序',
    rules: [{ required: true }],
  },
  {
    field: 'status',
    component: FormFieldType.RADIO_GROUP,
    label: '状态',
    componentProps: {
      options: [
        {
          label: '正常',
          value: '0',
        },
        {
          label: '停用',
          value: '1',
        },
      ],
    },
    defaultValue: '0',
  },
  {
    field: 'remark',
    component: FormFieldType.INPUT,
    label: '备注',
    componentProps: {
      type: 'textarea',
    },
    giProps: {
      span: 2,
    },
  },
];

export const searchSchemas: FormSchema[] = [
  {
    field: 'postCode',
    component: FormFieldType.INPUT,
    label: '岗位编码',
  },
  {
    field: 'postName',
    component: FormFieldType.INPUT,
    label: '岗位名称',
  },
  {
    field: 'status',
    component: FormFieldType.SELECT,
    label: '状态',
    componentProps: {
      options: [
        {
          label: '正常',
          value: '0',
        },
        {
          label: '停用',
          value: '1',
        },
      ],
      valueField: 'value',
    },
  },
];
